﻿using ChiDao.Business.Service.AttachAttribute;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.EnterpriseServices;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ChiDao.Business.Service;
using ChiDao.Site.Models.Security;

namespace ChiDao.Site.Web.Controllers
{
    /// <summary>
    /// 菜单Controller
    /// </summary>
    [Export]
    public class MenuInfoController : BaseController
    {
        #region 属性
        [Import]
        public IMenuInfoService MenuContract { get; set; }
        #endregion
        //
        // GET: /MenuInfo/
        [WebPage]
        [Description("菜单管理")]
        public ActionResult Index()
        {
            /*
             * 传入字典的模型项的类型为“System.Data.Entity.Infrastructure.DbQuery`1[ChiDao.Site.Models.Security.MenuInfoView]”，
             * 但此字典需要类型“System.Collections.Generic.List`1[ChiDao.Site.Models.Security.MenuInfoView]”的模型项
             */
            var menuInfoes = MenuContract.MenuInfoes.Select(m => new MenuInfoView
            {
                MenuCode = m.MenuCode,
                MenuName = m.MenuName,
                ActionName = m.ActionName,
                ControllerName = m.ControllerName,
                URL = m.URL
            });
            return View(menuInfoes.ToList());
        }
    }
}
